<?php
   class Model_packageprice extends CI_Model{
		protected $_table = "tbl_packageprice";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function getdata($id){
			$this->db->where("id",$id);
			return $this->db->get($this->_table)->row_array();
		}
		public function listall($limit,$start){
			return $this->db->get($this->_table)->result_array();
		}
		public function add($data){
        	$this->db->insert($this->_table,$data);
		}
		public function del($id){
			$this->db->where("id",$id);
			$this->db->delete($this->_table);
		}
		public function update($data,$id){
			$this->db->where("id",$id);
			$this->db->update($this->_table,$data);
		}
		public function getallbypackageid_date($packageid,$datefrom){
			$select="select * from tbl_packageprice ";
			$where=" where packageid=".$packageid;
			$order=" order by pricefor1";
			$max=" limit 0,1";
			if($datefrom!='') $where.=" and datefrom <='".$datefrom."' and dateto >='".$datefrom."' ";
			$query=$this->db->query($select.$where.$order.$max);
			return $query->row_array();
		}
		public function getallbypackageid($packageid){			
			$query=$this->db->query("select * from tbl_packageprice where packageid=".$packageid." order by pricefor1");
			return $query->result_array();
		}
	}
	?>